package com.service.Impl;

import com.entity.User;
import com.exception.GlobalException;
import com.github.pagehelper.PageInfo;
import com.mapper.UserMapper;
import com.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: UserInfoDaoImpl
 * Description:
 *
 * @author L_Z_R
 * @version 1.0
 * @create 2025/04/16 16:31
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private UserMapper userMapper;


    @Override
    public void updateUserInfoByAccountId(User user) {
        try {
            userMapper.updateUserInfoByAccountId(user);
        } catch (Exception e) {
            throw new GlobalException(1001, "用户信息更新失败");
        }
    }

    @Override
    public User selectUserInfoByAccountId(Integer accountId) {
        try {
            return userMapper.selectUserInfoByAccountId(accountId);
        } catch (Exception e) {
            throw new GlobalException(1001, "用户信息查询失败");
        }
    }

    @Override
    public PageInfo<User> getAllUnAuditUserInfo(int pageNum, int pageSize) {
        List<User> allUnAuditUserInfo = userMapper.getAllUnAuditUserInfo(pageNum, pageSize);
        return new PageInfo<>(allUnAuditUserInfo);
    }

    @Override
    public void auditUserInfo(Integer accountId, Integer auditStatus) {
        try {
            userMapper.auditUserInfo(accountId, auditStatus);
        } catch (Exception e) {
            throw new GlobalException(1001, "用户信息审核失败");
        }
    }
}